package org.sxp.common.web;

import org.sxp.modules.sys.entity.SysUserEntity;
import org.sxp.modules.sys.shiro.ShiroUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author shenxingping
 * @date 2021/01/29
 */
public class XpContextImpl implements XpContext {
    private Map properties = new HashMap();

    public XpContextImpl() {
    }

    @Override
    public SysUserEntity getCurrentUser() {
        return ShiroUtils.getUserEntity() == null ? new SysUserEntity() : ShiroUtils.getUserEntity();
    }

    @Override
    public Object getProperty(Object obj) {
        return this.properties.get(obj);
    }
    @Override
    public void addProperty(Object obj, Object obj1) {
        this.properties.put(obj, obj1);
    }
    @Override
    public void removeProperty(Object obj) {
        this.properties.remove(obj);
    }
    @Override
    public Map getProperties() {
        return this.properties;
    }
    @Override
    public void setProperties(Map map) {
        this.properties = map;
    }
    @Override
    public void removeAllProperties() {
        this.properties.clear();
    }
}
